package com.itheima.controller;

import com.itheima.pojo.Enterprise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Xiao
 * @date 2021/9/17
 */
@RestController
@RequestMapping("/books")
public class BookController {
    @Value("${lesson}")
    private String lesson;
    //@Value("${server.port}")
    private Integer port;
    @Value("${enterprise.subject[2]}")
    private String subject_03;

    @Autowired
    private Environment environment;

    @Autowired
    private Enterprise enterprise;

    @GetMapping("/{id}")
    public String getById(@PathVariable Integer id) {
        System.out.println("id --> " + id);
        System.out.println(lesson + "," + port + "," + subject_03);
        System.out.println("---------------");
        System.out.println(environment.getProperty("lesson"));
        System.out.println(environment.getProperty("logging.level.root"));
        System.out.println(environment.getProperty("enterprise.subject[0]"));
        System.out.println("---------------");
        System.out.println(enterprise);
        return "Hello SpringBoot!!!";
    }
}
